import os
import sys

sys.setrecursionlimit(20000)  # 提高递归限制

def dfs(u, visited, mp):
    visited[u] = True
    count = 1
    # 遍历当前节点下 还连接的边
    for i in mp[u]:
        if not visited[i]:
            # 递归遍历
            count += dfs(i, visited, mp)
    return count

n, m = map(int, input().split())
# 邻接表
mp = [[] for _ in range(n + 1)]
# 记录节点是否被访问过
visited = [False] * (n + 1)
ans = float('inf')

# 构建邻接表
for _ in range(m):
    v, u = map(int, input().split())
    # 无向图
    mp[v].append(u)
    mp[u].append(v)

# 遍历所有节点
for i in range(1, n + 1):
    if not visited[i]:
        # 计算当前连通分量的节点数
        cnt = dfs(i, visited, mp)
        # 每次更新最小答案
        ans = min(ans, cnt)

print(ans)